<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>getURLParam</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        var getURLParam = function (url) {
            let res = {};
            if (url.lastIndexOf('?') === -1) return res;
            let param = decodeURIComponent(url.slice(url.lastIndexOf('?') + 1));
            let keys = param.match(/(\w+\=)|\=/g);
            keys && (keys = keys.map(k => k.replace(/\=/g, '')));
            let values = param.match(/(\=(\w+|\s*)\&)|(\=(\w+|\s*))/g);
            values && (values = values.map(v => v.replace(/\&|\=/g, '')));
            keys && keys.forEach((k, i) => (res[k] = values[i]));
            return res;
        };
        let param = getURLParam('https://www.test.com/?_aaa=111&_bbb=222');
        console.log(param);
    </script>
</body>

</html>